package com.neural.infrastructure;

import java.util.List;

import javax.management.RuntimeErrorException;

import com.neural.descriptor.LayerDescriptor;

public class NormalLayer extends Layer {

	public NormalLayer(LayerDescriptor layerDescriptor, ILayer previousLayer) {
		super(layerDescriptor, previousLayer);
	}

	public void setNeuronValues(List<List<Double>> inputs) {
		if (inputs.size() * inputs.get(0).size() != neurons.size()) {
			throw new RuntimeErrorException(new Error());
		}
		for (int i = 0; i < inputs.size(); i++) {
			for (int j = 0; j < inputs.get(i).size(); j++) {
				neurons.get(i * inputs.get(i).size() + j).setValue(inputs.get(i).get(j));
			}
		}
	}

	@Override
	public void compute(Double learningSpeed, Double conscience, Double neighbourhood, List<Double> expectedResults) {
		for (Neuron neuron : neurons) {
			neuron.compute(activationMethod, learningSpeed, neighbourhood);
		}
	}
}
